<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ include file="/WEB-INF/jsp/common/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>用户列表</title>
<jsp:include page="../addlink.jsp" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/statics/css/common.min.css">
<link rel="stylesheet" type="text/css"	href="${pageContext.request.contextPath}/statics/css/system_list.css">
<script type="text/javascript">
	var userMgr = {
			getUserListPage:function(pageNo,pageSize){
				$.ajax({
					type:"GET",
					url:"${basePath}/sys/user/getUserList",
					dataType:'json',
					data:{"pageNo":pageNo,"pageSize":pageSize},
					success:function(data){
						if(checkTokenError(data)){
						//获取数据
						var userList = data.userList;
						console.log(userList.length);
						if(userList != null && userList.length>0){		
							var htmlTable = "";
							for(var i = 0; i < userList.length; i ++){
								htmlTable += "<tr>";							
								htmlTable += "<td>";
								htmlTable += userList[i].username;
								htmlTable += "</td>";
								htmlTable += "<td>";
								htmlTable += userList[i].deptName;
								htmlTable += "</td>";
								htmlTable += "<td>";
								htmlTable += userList[i].gender == 0?'男':'女';
								htmlTable += "</td>";
								htmlTable += "<td>";
								htmlTable += userList[i].phone;
								htmlTable += "</td>";
								htmlTable += "<td>";
								htmlTable += userList[i].loginName;
								htmlTable += "</td>";
								htmlTable += "<td>";						
								htmlTable += '<a  class="btn btn-default" href="${pageContext.request.contextPath}/sys/user/toUserEdit?userId='+userList[i].id+'&editFlag=2" role="button">操作</a>';
								htmlTable += "</td>";
							}	
							//取出分页条代码
							var pageStr = data.pageStr;
							$('#userPageInfo').html(pageStr);
						}else{
							htmlTable = "<tr><td colspan='5' align='right'>没有查询到数据</td><tr>";
							$('#userPageInfo').html("");		
						}
						$('#userListTable').find('tbody').html(htmlTable);
						}
					}
				});
			}	
	}
	$(function(){
		userMgr.getUserListPage(1,10);
	});
</script>
</head>
<body>

	<jsp:include page="../head.jsp" />

	<div class="container-fluid all">
		<jsp:include page="../menu.jsp" />
		<div class="maincontent">
			<ol class="breadcrumb">
				<li class="url-root"><a>系统设置</a></li>
				<li class="url-root"><a>用户管理</a></li>
				<li class="active">用户列表</li>
			</ol>
			<div class="control_bar row">
				<div class="control_left">
					<a class="btn btn-default"
						href="${basePath}/sys/user/toUserEdit?editFlag=1"
						role="button">添加</a>
				</div>

				<div class="control_right">
					<select class="form-control">
						<option>根据系统角色排序</option>
					</select>
				</div>
			</div>
<div class="mode">
			<table class="table table-hover" id="userListTable">
				<thead>
					<tr>
						<th>姓名</th>
						<th>部门</th>
						<th>性别</th>
						<th>手机号码</th>
						<th>登录名</th>
						<!-- <th>角色</th> -->
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<%-- <tr>
						<td>1</td>
						<td>张三</td>
						<td>男</td>
						<td>1543234567</td>
						<td>Dijon</td>
						<td>系统管理员</td>
						<td><a class="btn btn-default"
							href="${pageContext.request.contextPath}/useradd/test"
							role="button">修改</a></td>
					</tr> --%>				
				</tbody>
			</table>
			<div class="pagination" id = "userPageInfo">
</div>
		</div>
	</div>
	</div>	
	<jsp:include page="../foot.jsp" />
</body>
</html>
